var strArray = location.search;
orderId = strArray.split("?")[1].split("=")[1];
console.log("传过来的orderId====="+orderId)

var newTime = timeAll();
// 本类的项目
function ajaxtest(data) {
    var timestamp = "productCategoryId:"+"01"+"BM"+"timeStamp:" + newTime + "BM";
    var signs = md5(timestamp);
    signs = signs.toUpperCase();
    // console.log(signs)
    // console.log(newTime)
    $.ajax({
        type: "get",
        url: webUrl + "orderProcessing/brand",
        data: {
            "productCategoryId": '01',
            "sign": signs,
            "timeStamp": newTime,
        },
        dataType: "JSON",
        async: false,
        success: function (data) {
            console.log(data);
            $("#list").html(data)
            if (data.status == 200) {
                var str;
                for (var i = 0; i < data.data.length; i++) {
                    str= '<ul class="left-item">'+'<li onclick=ss(\"'+data.data[i].id+'\")>'
                        + data.data[i].brandNameChn +
                        '</li>'+'</ul>';
                    $("#tab").append(str);
                    var ls = document.getElementById("tab").getElementsByTagName("li");
                    ls[0].className="selected"
                    textTab();
                    ss(data.data[0].id)
                }
            }else if ( data.status == 300 ) {
                document.location.href = '../login/login.html';
            } else {
                alert(data.msg)
            }
        }
    })
}

function textTab() {
    //获取index下标
    var $tab_li = $('#tab ul li');
    // 初始化index
    var index = $tab_li.index(0)
    $tab_li.click(
        function () {
            $tab_li.removeClass('selected')
            $(this).addClass('selected').siblings().removeClass('selected');
            index = $tab_li.index(this);
            $('html,body').animate({scrollTop: '0px'}, 800);
        }
    );
}



function ss(id) {
    var timestamp = "brandId:"+ id+"BM"+"timeStamp:" + newTime + "BM";
    var signs = md5(timestamp);
    signs = signs.toUpperCase();
    console.log(id)
    console.log(signs)
    console.log(newTime)
    $.ajax({
        type: "post",
        url: webUrl + "orderProcessing/phone/list",
        data: {
            "brandId": id,
            "sign": signs,
            "timeStamp": newTime,
        },
        dataType: "JSON",
        async: false,
        success: function (data) {
            console.log(data);
            $("#brandList").html(data)
            if (data.status==200){
                var listStr;
                var imgStr;
                var j=0;
                for (var i=0;i<data.data.length;i++){
                    listStr= '<div class="Right-item" onclick=typeClick(\"'+data.data[i].id+'\")>';
                    j=j+1;
                    imgStr= '<div class="text-img">' +j+
                        '</div>';
                    listStr=listStr+imgStr+ '<div>' +data.data[i].productNameChn+
                        '</div>' +
                        '</div>';
                    $('#brandList').append(listStr)
                }
            }else if ( data.status == 300 ) {
                document.location.href = '../html/login.html';
            } else {
                alert(data.msg)
            }
        }

    })
}


function typeClick(id) {
    console.log(id)
    document.location.href = '../aginChoose/aginChoose.html?productId='+id+"?orderId="+orderId;
}




